﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BBD_DAL.Entities
{
	[Flags]
	public enum Regions
	{
		Unknown = 0x00,
		North = 0x01,
		West = 0x02,
		East = 0x04,
		South = 0x08,
		Central = 0x0F
	}

	public enum Sex
	{
		Male, Female, NotDefined
	}

	public enum States
	{
		Unknown,
		Dolnoslaskie,
		KujawskoPomorskie,
		Lubelskie,
		Lubuskie,
		Lodzkie,
		Malopolskie,
		Mazowieckie,
		Opolskie,
		Podkarpackie,
		Podlaskie,
		Pomorskie,
		Slaskie,
		Swietokrzyskie,
		WarminskoMazurskie,
		Wielkopolskie,
		Zachodniopomorskie
	}

	public static class RegionExtention
	{
		public static string GetRegionFullName(this Regions e)
		{
			switch ((short)e)
			{
				case (short)(Regions.North | Regions.East):
					return "Północny-wschód";

				case (short)(Regions.North | Regions.West):
					return "Północny-zachód";

				case (short)(Regions.South | Regions.East):
					return "Południowy-wschód";

				case (short)(Regions.South | Regions.West):
					return "Południowy-zachód";

				case (short)Regions.North:
					return "Północ";

				case (short)Regions.South:
					return "Południe";

				case (short)Regions.East:
					return "Wschód";

				case (short)Regions.West:
					return "Zachód";

				case (short)Regions.Central:
					return "Centrum";

				case (short)Regions.Unknown:
				default:
					return "Nieznany";
			}
		}

		public static string GetRegionCode(this Regions e)
		{
			switch ((short)e)
			{
				case (short)(Regions.North | Regions.East):
					return "pnw";

				case (short)(Regions.North | Regions.West):
					return "pnz";

				case (short)(Regions.South | Regions.East):

					return "plw";

				case (short)(Regions.South | Regions.West):
					return "plz";

				case (short)Regions.North:
					return "pn";

				case (short)Regions.South:
					return "pl";

				case (short)Regions.East:
					return "w";

				case (short)Regions.West:
					return "z";

				case (short)Regions.Central:
					return "c";

				case (short)Regions.Unknown:
				default:
					return "u";
			}
		}

		public static void GetRegionFromCode(this Regions e, string code)
		{
			switch (code.ToLower())
			{
				case "w":
					e = Regions.East;
					break;
				case "c":
					e = Regions.Central;
					break;
				case "z":
					e = Regions.West;
					break;
				case "pn":
					e = Regions.North;
					break;
				case "pl":
					e = Regions.South;
					break;
				case "pnw":
					e = Regions.North | Regions.East;
					break;
				case "pnz":
					e = Regions.North | Regions.West;
					break;
				case "plw":
					e = Regions.South | Regions.East;
					break;
				case "plz":
					e = Regions.South | Regions.West;
					break;
				default:
					e = Regions.Unknown;
					break;
			}
		}
	}

	public static class StateExtention
	{
        public static States GetState(this States e, string name)
		{
			switch (name.ToLower())
			{
				case "dolnośląskie":
					e = States.Dolnoslaskie;
					break;

				case "kujawskopomorskie":
					e = States.KujawskoPomorskie;
					break;

				case "łódzkie":
					e = States.Lodzkie;
					break;

				case "lubelskie":
					e = States.Lubelskie;
					break;

				case "lubuskie":
					e = States.Lubuskie;
					break;

				case "małopolskie":
					e = States.Malopolskie;
					break;

				case "mazowieckie":
					e = States.Mazowieckie;
					break;

				case "opolskie":
					e = States.Opolskie;
					break;

				case "podkarpackie":
					e = States.Podkarpackie;
					break;

				case "podlaskie":
					e = States.Podlaskie;
					break;

				case "pomorskie":
					e = States.Pomorskie;
					break;

				case "śląskie":
					e = States.Slaskie;
					break;

				case "świętokrzyskie":
					e = States.Swietokrzyskie;
					break;

				case "warmińskomazurskie"://case "warmińskopomorskie"://ma byc warmińskomazurskie a nie warmińskopomorskie
					e = States.WarminskoMazurskie;
					break;

				case "wielkopolskie":
					e = States.Wielkopolskie;
					break;

				case "zachodniopomorskie":
					e = States.Zachodniopomorskie;
					break;

				case "nieznane":
				default:
					e = States.Unknown;
					break;
			}

            return e;
		}

		public static string GetStateFullName(this States e)
		{
			switch (e)
			{
				case States.Dolnoslaskie:
					return "Dolnośląskie";

				case States.KujawskoPomorskie:
					return "Kujawsko-Pomorskie";

				case States.Lodzkie:
					return "Łódzkie";

				case States.Lubelskie:
					return "Lubelskie";

				case States.Lubuskie:
					return "Lubuskie";

				case States.Malopolskie:
					return "Małopolskie";

				case States.Mazowieckie:
					return "Mazowieckie";

				case States.Opolskie:
					return "Opolskie";

				case States.Podkarpackie:
					return "Podkarpackie";

				case States.Podlaskie:
					return "Podlaskie";

				case States.Pomorskie:
					return "Pomorskie";

				case States.Slaskie:
					return "Śląskie";

				case States.Swietokrzyskie:
					return "Świętokrzyskie";

				case States.WarminskoMazurskie:
					return "Warmińsko-Mazurskie";

				case States.Wielkopolskie:
					return "Wielkopolskie";

				case States.Zachodniopomorskie:
					return "Zachodniopomorskie";

				case States.Unknown:
				default:
					return "Nieznane";
			}
		}
	}

	public static class SexExtention
	{
		public static string GetSexCode(this Sex e)
		{
			switch (e)
			{
				case Sex.Female:
					return "f";

				case Sex.Male:
					return "m";

				case Sex.NotDefined:
				default:
					return null;
			}
		}

		public static Sex GetSex(this Sex e, string code)
		{
			switch (code)
			{
				case "f":
				case "kobieta":
					return Sex.Female;

				case "m":
				case "mężczyzna":
					return Sex.Male;

				default:
					return Sex.NotDefined;
			}
		}

	}
}
